# Python 2.6.4
# Project Euler, Problem 65
# Copyright 2010 Talha Zaman

def next(num, den, seq):
    num += seq*den
    return den, num

def eseq(n):
    if n==1: return 2
    if n%3==0: return 2*n/3
    return 1

def efrac(n):
    num = 1
    den = eseq(n)
    for i in range(n-1, 0, -1):
        num, den = next(num, den, eseq(i))
    return den, num

num, den = efrac(100)
print sum(int(digit) for digit in str(num))
